Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.IO

Namespace C4F.DevKit.WebServicesDemo
	Public Partial Class DemoHost
		Inherits Form
		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub DemoHost_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
			AddHandler Application.ThreadException, AddressOf Application_ThreadException
		End Sub

		Private Sub Application_ThreadException(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs)
			Dim ex As Exception = e.Exception
			If TypeOf ex Is System.Net.WebException Then
				Dim WebEx As System.Net.WebException = TryCast(ex, System.Net.WebException)
				Dim streamReader As StreamReader = New StreamReader(WebEx.Response.GetResponseStream())
				Dim responseData As String = streamReader.ReadToEnd()
				streamReader.Close()
				MessageBox.Show(responseData)
			Else
				MessageBox.Show(ex.Message)
			End If
		End Sub
	End Class
End Namespace
